package com.yuexun.dhdoctor.module.patientIntegral.ui;

import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.yuexun.dhdoctor.R;
import com.yuexun.dhdoctor.base.BaseKJActivity;
import com.yuexun.dhdoctor.module.patientIntegral.adapter.PatientIntegralListAdapter;
import com.yuexun.dhdoctor.module.patientIntegral.bean.PatientIntegralBean;
import com.yuexun.dhdoctor.widget.EmptyLayout;
import com.yuexun.dhdoctor.widget.PullToRefresh.FooterLoadingLayout;
import com.yuexun.dhdoctor.widget.PullToRefresh.PullToRefreshBase;
import com.yuexun.dhdoctor.widget.PullToRefresh.PullToRefreshList;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2018/5/21 0021.
 */

public class Act_PatientIntegral_Main extends BaseKJActivity {

    @Bind(R.id.pull_list)
    PullToRefreshList pullList;
    @Bind(R.id.empty_layout)
    EmptyLayout emptyLayout;

    private PatientIntegralListAdapter adapter;
    private List<PatientIntegralBean> datas = new ArrayList<>();

    private int nowpage = 1;
    private int pagesize = 9999;

    private String key = "";
    private String type = "";

    @Override
    public void setRootView() {
        setContentView(R.layout.act_patientintegral_main);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        super.initData();
        listViewPreference();
    }

    /**
     * 初始化ListView样式
     */
    private void listViewPreference() {
        ListView mList = pullList.getRefreshView();
        mList.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
        pullList.setPullRefreshEnabled(false);
        pullList.setPullLoadEnabled(true);
        ((FooterLoadingLayout) pullList.getFooterLoadingLayout()).setNoMoreDataText("无更多数据");

        datas.add(new PatientIntegralBean("1"));
        datas.add(new PatientIntegralBean("2"));
        emptyLayout.dismiss();

        adapter = new PatientIntegralListAdapter(mList, datas, R.layout.item_patientintegral_list);
        mList.setAdapter(adapter);

        pullList.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
//                nowpage = nowpage + 1;
//                ApiForGetList(type, key);
            }
        });

        mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                Intent intent = new Intent(getActivity(), Act_Blood_Detail.class);
//                intent.putExtra("requireNo", datas.get(position).getRequireNo());
//                intent.putExtra("title", "用血记录详情");
//                startActivity(intent);
            }
        });
    }

    @OnClick({R.id.title_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_back:
                finish();
                break;
        }
    }
}
